% COVER PAGE FOR IC-UNICAMP TECHNICAL REPORTS
% Last edited on 2001-04-03 04:27:30 by stolfi
% Based on rel-tec-ic.sty of 23 May 1996, by Pedro J. de Rezende.
%
% The package techrep-ic defines a \TRMakeCover macro that 
% prints a cover page for the standard IC-Unicamp technical report
% format. The various cover fields (title, author, report number, etc.)
% are defined by auxiliary macros \TRTitile, \TRAuthor, \TRMonth, etc.
%
% Modified Jun 1997 by J. Stolfi:
%   Removed list of previous reports.
%   Modified to work also as a LaTeX 2e package.
%
% Modified Aug 1997 by J. Stolfi:
%   Reset the page counter to zero on cover page.
%
% Modified Fev 2001 by J. Stolfi:
%   Added macros \TRAuthor, \TRTitle.
%   Redefined \TRMonth to take a numeric month.
%   Redefined \TRNumber to take 3 digits.
%   Added the Institute's name, logo, and color background.
%   

% Hack to set \endlinechar negative without losing the old value:
\advance\endlinechar by -256%

\ifx\xipt\undefined
  \typeout{LaTeX 2e package `techrep-ic' -- Released 25 Feb 2001}
  \ifx\pagecolor\undefined
    \usepackage{color}
  \fi
\else
  \typeout{LaTeX 2.09 style option `techrep-ic' -- Released 25 Feb 2001}
\fi

% Margins:

  \topmargin=0.00in
  \oddsidemargin=0.225in
  \evensidemargin=\oddsidemargin
  \marginparwidth=\evensidemargin

% Dimensions of text:

  \textheight=8.25in
  \textwidth=6.00in

% These macros should be used by the author, before the \maketitle,
% to define the report number and date:

  \def\TRTitle#1{\def\TRtitl@{#1}}
  \TRTitle{A Generic Technical Report}

  \def\TRAuthor#1{\def\TRauth@r{#1}}
  \TRAuthor{Generic Author One and Generic Author Two and Generic Author Three}

  \def\TRNumber#1{\def\TRnumb@r{#1}}
  \TRNumber{025}

  \def\TRYear#1{\def\TRye@r{#1}}
  \TRYear{01}

  \def\TRMonth#1{\def\TRm@nth{#1}}
  \TRMonth{\month}
  
% Handy macro for current month and year, in Portuguese:

  \def\TRm@nthP{
    \ifcase\TRm@nth\or
    Janeiro\or Fevereiro\or Mar\c{c}o\or 
    Abril\or Maio\or Junho\or 
    Julho\or Agosto\or Setembro\or 
    Outubro\or Novembro\or Dezembro\fi
  }

  \def\TRm@nthE{
    \ifcase\TRm@nth\or
    January\or February\or March\or 
    April\or May\or June\or 
    July\or August\or September\or 
    October\or November\or December\fi
  }

% Cover page design

  \newcommand{\TRf@tbox}[2]{
    \vbox{\offinterlineskip
      \null\kern#1
      \hbox{\null\kern#1#2\kern#1\null}
      \kern#1\null
    }
  }
  
% Color boxes

  \ifx\colorbox\undefined
    \newcommand{\TRc@lorbox}[2]{\hbox{#2}}
  \else
    \newcommand{\TRc@lorbox}[2]{\colorbox{#1}{#2}}
  \fi
  \renewcommand{\TRc@lorbox}[2]{\hbox{#2}}

% Cover page main font style

  \ifx\xipt\undefined
    % (LaTeX 2e)
    \newcommand{\TR@sf}[1]{{\usefont{T1}{cmss}{m}{n}#1}}
    \newcommand{\TR@bf}[1]{{\usefont{T1}{cmr}{bx}{n}#1}}
    \newcommand{\TR@it}[1]{{\usefont{T1}{cmr}{m}{it}#1}}
    \newcommand{\TR@Huge}{\fontsize{25}{30pt}}
    \newcommand{\TR@LARGE}{\fontsize{17}{22pt}}
    \newcommand{\TR@normal}{\fontsize{11}{13.6pt}}
    \newcommand{\TR@small}{\fontsize{10}{12pt}}
    \DeclareMathSizes{11}{11}{8}{5}
  \else
    % (LaTeX 2.09)
    \newcommand{\TR@sf}[1]{{\sf#1}}
    \newcommand{\TR@bf}[1]{{\bf#1}}
    \newcommand{\TR@it}[1]{{\it#1}}
    % \newcommand{\TR@sf}[1]{{#1}}
    \newcommand{\TR@Huge}{\Huge}
    \newcommand{\TR@LARGE}{\LARGE}
    \newcommand{\TR@normal}{\normalsize}
    \newcommand{\TR@small}{\small}
  \fi
  \def\TR@titwd{11.7cm}
  % \def\TR@titwd{12.7cm}

% The classical IC-Unicamp abacus logo 

  % Original design by Hans K. E. Liesenberg
  % Macros by Tomasz Kowaltowski - mar/1988, revised mar/1991
  % Usage: \TRAbacus{d1}{d2}{d3}{d4}{width}
  %   where d1--d4 are the digits tobe displayed.

  % Empty bead slot
  \newsavebox{\TR@o}
  \newsavebox{\TR@x}
  \newsavebox{\TR@h}

  \newcommand{\TRAbacus}[5]{
    \setlength{\unitlength}{#5}
    \divide \unitlength by 24
    \begin{picture}(24,25)(0,0)
      
      % Empty bead half-slot
      \savebox{\TR@h}(1,4){
        \begin{picture}(1,4)(0,0)
          \put(0,1.5){\line(1,0){1}}
          \put(0,2.5){\line(1,0){1}}
        \end{picture}
      }

      % Empty bead slot
      \savebox{\TR@x}(2,4){
        \begin{picture}(2,4)(0,0)
          \put(0,1.5){\line(1,0){2}}
          \put(0,2.5){\line(1,0){2}}
        \end{picture}
      }

      % Occupied bead slot
      \savebox{\TR@o}(2,4){
        \begin{picture}(2,4)(0,0)
          \put(1,2){\oval(2,4)}
        \end{picture}
      }

      \thinlines
      % Outer frame border
      \put(0,0)  {\line(0,1){25}}
      \put(0,0)  {\line(1,0){24}}
      \put(24,0) {\line(0,1){25}}
      \put(0,25) {\line(1,0){24}}

      % Inner frame border
      \put(1.9,1.9)  {\line(0,1){21.2}}
      \put(14.1,1.9) {\line(0,1){21.2}}
      \put(1.9,1.9)  {\line(1,0){12.2}}
      \put(1.9,23.1) {\line(1,0){12.2}}

      \put(15.9,1.9) {\line(0,1){21.2}}
      \put(22.1,1.9) {\line(0,1){21.2}}
      \put(15.9,1.9) {\line(1,0){6.2}}
      \put(15.9,23.1){\line(1,0){6.2}}

      % Joint lines
      % \put(14.1,1.9) {\line(1,-1){0.95}}
      % \put(15.9,23.1){\line(1,1){0.95}}
      % \put(17,24)    {\line(1,-1){0.95}}
      % \put(17,1)     {\line(1,1){0.95}}
      % 
      % \put(0,0)  {\line(1,1){1.9}}
      % \put(0,25) {\line(1,-1){1.9}}
      % \put(24,0) {\line(-1,1){1.9}}
      % \put(24,25){\line(-1,-1){1.9}}

      % Digits
      \thicklines
      \put(2,18) {\TR@bacusDigit{#1}}
      \put(2,13) {\TR@bacusDigit{#2}}
      \put(2,8)  {\TR@bacusDigit{#3}}
      \put(2,3)  {\TR@bacusDigit{#4}}

    \end{picture}
  }

  \newcommand{\TR@bacusDigit}[1]{
    \begin{picture}(22,4)(0,0)\relax
      \xdef\TR@fiv{\ifcase#1 0\or0\or0\or0\or0\or1\or1\or1\or1\or1\fi}
      \xdef\TR@nun{\ifcase#1 0\or1\or2\or3\or4\or0\or1\or2\or3\or4\fi}
      \put(0,0){\TR@bacusUnits{\TR@nun}}
      \put(14,0){\TR@bacusFives{\TR@fiv}}
    \end{picture}
  }
  
  \newcommand{\TR@bacusUnits}[1]{
    \begin{picture}(12,4)(0,0)\relax
      \xdef\TR@xlo{0}
      \xdef\TR@nlo{\ifcase#1 5\or4\or3\or2\or1\or0\fi}
      \multiput(\TR@xlo,0)(2,0){\TR@nlo}{\usebox{\TR@o}}

      \xdef\TR@xmd{\ifcase#1 10\or8\or6\or4\or2\or0\fi}
      \put(\TR@xmd,0){\usebox{\TR@x}}

      \xdef\TR@xhi{\ifcase#1 12\or10\or8\or6\or4\or2\fi}
      \xdef\TR@nhi{#1}
      \multiput(\TR@xhi,0)(2,0){\TR@nhi}{\usebox{\TR@o}}
    \end{picture}
  }

  \newcommand{\TR@bacusFives}[1]{
    \begin{picture}(6,4)(0,0)\relax
      \xdef\TR@xlo{0}
      \xdef\TR@nlo{#1}
      \multiput(\TR@xlo,0)(2,0){\TR@nlo}{\usebox{\TR@o}}

      \xdef\TR@xmd{\ifcase#1 0\or2\or4\fi}
      \put(\TR@xmd,0){\usebox{\TR@x}}

      \xdef\TR@xhi{\ifcase#1 2\or4\or6\fi}
      \xdef\TR@nhi{\ifcase#1 2\or1\or0\fi}
      \multiput(\TR@xhi,0)(2,0){\TR@nhi}{\usebox{\TR@o}}
    \end{picture}
  }

% \TRMakeCover creates the cover page:

  \newsavebox{\TR@tmpbox}
  
  \def\TRMakeCover{
    \bgroup
      \newpage
      \c@page\z@
      \thispagestyle{empty}
      \parindent 0pt
      \parskip 0pt
%%       \ifx\xipt\undefined
%%         % (LaTeX 2e)
%%         \definecolor{TRpink}{rgb}{1.00,0.90,1.00}
%%         \definecolor{TRBlue}{rgb}{0.70,0.85,1.00}
%%         \pagecolor{TRpink}
%%       \else
%%         % (LaTeX 2.09)
%%         \xipt 
%%       \fi
      \TR@normal
      \null
      \vskip -1cm
      \vbox to 0pt{
        \null\kern -6cm 
        \hbox to 0pt{
          \null\kern -4cm
          \TRc@lorbox{TRBlue}{\rule{0cm}{32cm}\rule{5.5cm}{0cm}}
          \hss
        }
        \vss
      }
      \begin{center}
        \leavevmode
        \hbox to 10pt{
          \null\hss
          \TRc@lorbox{white}{
            \TRf@tbox{5pt}{
              \valign{\vfil##\vfil\cr
                \hbox{\TRAbacus{1}{9}{6}{9}{60pt}}
                \cr
                \noalign{\kern 10pt}
                \hbox{
                  \begin{minipage}[c]{\TR@titwd} % was 12.7cm when  \textsf{}
                    \parfillskip 0pt\parskip 0pt
                    {\TR@Huge\TR@sf{INSTITUTO DE COMPUTA{\c{C}}{\~A}O}\par}
                    \vskip 5pt
                    {\TR@LARGE\TR@sf{UNIVERSIDADE ESTADUAL DE CAMPINAS}\par}
                  \end{minipage}
                }
                \cr
                \noalign{\kern 20pt}
              }
            }
          }
          \hss
          \null
        }
        \vskip 93mm
        \TRc@lorbox{white}{
          \TRf@tbox{4mm}{
            \framebox[95mm]{
              \vbox to 45mm{
                \hsize=90mm
                \textwidth=\hsize
                \linewidth=\hsize
                \null
                {\centering
                  \null
                  \baselineskip 12pt
                  \lineskip 1pt plus 3pt minus 0pt
                  \lineskiplimit 1pt
                  \vfill
                  \TR@normal\TR@bf{\TRtitl@\par}
                  \vskip 1.5ex
                  \TR@normal\TR@it{
                    \def\and{\end{tabular}\hskip 1em plus .17fil\begin{tabular}[t]{c}}
                    \begin{tabular}[t]{c}
                      \TRauth@r
                    \end{tabular}
                    \par
                  }
                  \vfill
                  \TR@normal\TR@sf{
                    Technical Report
                    \quad-\quad
                    IC-{\TRye@r}-{\TRnumb@r}
                    \quad-\quad
                    Relat{\'o}rio T{\'e}cnico
                  }
                  \par
                  \kern -5pt
                  \null
                }
                \null
              }
            }
          }
        }
        \vskip 5mm
        { 
          \TR@normal\TR@sf{
            {\TRm@nthE}
            \quad-\quad
            20{\TRye@r}
            \quad-\quad
            {\TRm@nthP}
          }
        }
        \par\vskip 5mm
        { 
          \TR@small
          \TR@sf{The contents of this report are the sole responsibility {}
          of the authors.}
          \par
          \TR@sf{O conte{\'u}do do presente relat{\'o}rio {\'e} de {\'u}nica {}
          responsabilidade dos autores.}
          \par
        }
        \vfill
      \end{center}
    \egroup
    \c@page\z@
    \newpage
    \ifx\xipt\undefined
      \pagecolor{white}
    \fi
  }

% Restore \endlinechar:
\advance\endlinechar by +256%
